package cn.xgx.config;

import cn.xgx.web.interceptor.LoginForUserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginForUserInterceptor())
                .addPathPatterns("/api/backstage/**")    //要拦截的路径
                .excludePathPatterns("/api/backstage/login");    //不拦截的路径

    }

    //后台登录验证拦截器
    @Bean
    public LoginForUserInterceptor loginForUserInterceptor() {
        return new LoginForUserInterceptor();
    }

}
